package com.coolbi.security.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;

import com.coolbi.security.dao.RoleUrlDao;
import com.coolbi.security.entity.RoleUrl;
import com.coolbi.security.entity.Roles;
import com.coolbi.security.mapper.RoleUrlMapper;

public class RoleUrlDaoImpl implements RoleUrlDao {
	
	@Autowired
	private RoleUrlMapper roleUrlMapper;
	public void setRoleUrlMapper(RoleUrlMapper roleUrlMapper) {
		this.roleUrlMapper = roleUrlMapper;
	}

	@Override
	public List<RoleUrl> find(Map<String, Object> parameter) {
		return roleUrlMapper.listByParameter(parameter);
	}

	@Override
	public List<RoleUrl> find(Map<String, Object> parameter, int offset, int limit) {
		parameter.put("offset", offset);
		parameter.put("limit", limit);
		return roleUrlMapper.listByParameterPage(parameter);
	}

	@Override
	public int count(Map<String, Object> parameter) {
		return roleUrlMapper.countByParameter(parameter);
	}

	@Override
	public List<RoleUrl> search(String keyword, int offset, int limit) {
		Map<String, Object> parameter=new HashMap<String, Object>();
		parameter.put("keyword", keyword);
		parameter.put("offset", offset);
		parameter.put("limit", limit);
		return roleUrlMapper.search(parameter);
	}

	@Override
	public int countByKeyword(String keyword) {
		Map<String, Object> parameter=new HashMap<String, Object>();
		parameter.put("keyword", keyword);
		return roleUrlMapper.countByKeyword(parameter);
	}

	@Override
	public RoleUrl save(RoleUrl obj) {
		roleUrlMapper.save(obj);
		return obj;
	}

	@Override
	public int update(RoleUrl obj) {
		return roleUrlMapper.update(obj);
	}

	@Override
	public int delete(long id) {
		return roleUrlMapper.delete(id);
	}

	@Override
	public RoleUrl get(long id) {
		return roleUrlMapper.get(id);
	}

	@Override
	public List<RoleUrl> list() {
		return roleUrlMapper.list();
	}

	@Override
	public List<RoleUrl> list(int offset, int limit) {
		Map<String, Object> parameter=new HashMap<String, Object>();
		parameter.put("offset", offset);
		parameter.put("limit", limit);
		return roleUrlMapper.listByPage(parameter);
	}

	@Override
	public int count() {
		return roleUrlMapper.count();
	}

	@Override
	public List<RoleUrl> findUrlByRoles(List<Roles> roles) {
		return roleUrlMapper.findUrlByRoles(roles);
	}

	@Override
	public int updateOrderNo(RoleUrl roleUrl) {
		return roleUrlMapper.updateOrderNo(roleUrl);
	}

	@Override
	public int updateNameInTree(RoleUrl roleUrl) {
		return roleUrlMapper.updateNameInTree(roleUrl);
	}

	@Override
	public int countByUrlName(String urlName) {
		return roleUrlMapper.countByUrlName(urlName);
	}

	@Override
	public int countByUrl(String url) {
		return roleUrlMapper.countByUrl(url);
	}
}
